package com.xin.data.simbapesa.dialog;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.xin.data.simbapesa.R;
import com.xin.data.simbapesa.base.BaseDialog;
import com.xin.data.simbapesa.databinding.SimbaAccountDeleteBinding;
import com.xin.data.simbapesa.utils.ViewUtils;

public class DeleteDialog extends BaseDialog<SimbaAccountDeleteBinding> {
    public DeleteDialog(@NonNull Context context) {
        super(context);
    }

    public DeleteDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected DeleteDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected SimbaAccountDeleteBinding initViewBinding(LayoutInflater inflater) {
        return SimbaAccountDeleteBinding.inflate(inflater);
    }

    @Override
    protected void initView() {
        binding.tvCancel.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            dismiss();
            if (onBtnClickListener != null) {
                onBtnClickListener.btnOnClickCancel();
            }
        });
        binding.tvOk.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            dismiss();
            if (onBtnClickListener != null) {
                onBtnClickListener.btnOnClickOk();
            }
        });
        binding.tvClose.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            if (onBtnClickListener != null) {
                onBtnClickListener.btnOnClickColse();
            }
            dismiss();
        });
    }

    public void setIcon(String url) {
        Glide.with(getContext()).load(url).placeholder(R.color.placeholder_icon).into(binding.tvIcon);
    }

    public void setTitle(String str) {
        binding.tvTitle.setText(str);
    }

    public void setSubTitle(String str) {
        binding.tvSubTitle.setText(str);
    }

}
